package cn.edu.nju.software.cdiy.algorithm.performance;

import cn.edu.nju.software.cdiy.bean.Graphics;
import cn.edu.nju.software.cdiy.util.Constant;

public class GraphicsEvaluator implements Evaluator<Graphics>{

	@Override
	public double getPerformance(Graphics t) {
		double score = 0;
		
		//显存得分
		String videoMemCapacity = t.getVideoMemCapacity().getValue();
		double videoMemCapacityScore = getVideoMemCapacityBase(videoMemCapacity)*Constant.GRA_STD_VIDEOMEMCAPACITY;
		
		//位宽得分
		String videoMemBitWide = t.getVideoMemBitWide().getValue();
		double videoMemBitWideScore = getVideoMemBitWideBase(videoMemBitWide)*Constant.GRA_STD_VIDEOMEMBITWIDE;
		
		//显存类型得分
		String videoMemType = t.getVideoMemType().getValue();
		double videoMemTypeScore = getVideoMemTypeBase(videoMemType)*Constant.GRA_STD_VIDEOMEMTYPE;
		
		//核心频率得分
		int coreFrequency = t.getCoreFrequency();
		double coreFrequencyScore = getCoreFrequencyBase(coreFrequency)*Constant.GRA_STD_COREFREQUENCY;
		
		//显存频率得分
		int videoMemFrequency = t.getVideoMemFrequency();
		double videoMemFrequencyScore = getVideoMemFrequencyBase(videoMemFrequency)*Constant.GRA_STD_VIDEOMEMFREQUENCY;
		
		
		score = videoMemCapacityScore+videoMemBitWideScore+videoMemTypeScore+coreFrequencyScore+videoMemFrequencyScore;
		return score;
	}

	private double getVideoMemFrequencyBase(int videoMemFrequency) {
		/*
		 * 显存频率基础分
		 * 1000以下			50
		 * 1000-2000		60
		 * 2000-3000		70
		 * 3000-4000		80
		 * 4000-5000		85
		 * 5000以上			90
		 * */
		if(videoMemFrequency<1000)
			return 50;
		else if(videoMemFrequency>=1000 && videoMemFrequency<2000)
			return 60;
		else if(videoMemFrequency>=2000 && videoMemFrequency<3000)
			return 70;
		else if(videoMemFrequency>=3000 && videoMemFrequency<4000)
			return 80;
		else if(videoMemFrequency>=4000 && videoMemFrequency<5000)
			return 85;
		else if(videoMemFrequency>=5000)
			return 90;
		else return 95;
	}

	private double getCoreFrequencyBase(int coreFrequency) {
		/*
		 * 核心频率基础分
		 * 500以下		65
		 * 500-600		70
		 * 600-700		75
		 * 700-800		80
		 * 800-900		85
		 * 900-1000		90
		 * 1000以上		95
		 * */
		if(coreFrequency<500)
			return 65;
		else if(coreFrequency>=500 && coreFrequency<600)
			return 70;
		else if(coreFrequency>=600 && coreFrequency<700)
			return 75;
		else if(coreFrequency>=700 && coreFrequency<800)
			return 80;
		else if(coreFrequency>=800 && coreFrequency<900)
			return 85;
		else if(coreFrequency>=900 && coreFrequency<1000)
			return 90;
		else if(coreFrequency>=1000)
			return 95;
		else return 95;
	}


	private double getVideoMemTypeBase(String videoMemType) {
		/*
		 * 显存类型基础分
		 * GDDR2		65
		 * GDDR3		75
		 * GDDR5		90
		 * */
		if(videoMemType.equals("GDDR2"))
			return 65;
		else if(videoMemType.equals("GDDR3"))
			return 75;
		else if(videoMemType.equals("GDDR5"))
			return 90;
		else return 90;
	}

	private double getVideoMemBitWideBase(String videoMemBitWide) {
		/*
		 * 显存位宽基础分
		 * 64			50
		 * 128			55
		 * 192			60
		 * 256			65
		 * 320			70
		 * 384			75
		 * 512			80
		 * 768			90
		 * */
		if(videoMemBitWide.equals("64bit"))
			return 50;
		else if(videoMemBitWide.equals("128bit"))
			return 55;
		else if(videoMemBitWide.equals("192bit"))
			return 60;
		else if(videoMemBitWide.equals("256bit"))
			return 65;
		else if(videoMemBitWide.equals("320bit"))
			return 70;
		else if(videoMemBitWide.equals("384bit"))
			return 75;
		else if(videoMemBitWide.equals("512bit"))
			return 80;
		else if(videoMemBitWide.equals("768bit"))
			return 90;
		else return 90;
	}

	private double getVideoMemCapacityBase(String videoMemCapacity) {
		/*
		 * 显存容量基础分
		 * 128			40
		 * 256			45
		 * 512			50
		 * 768			55
		 * 1			60
		 * 1.25			65
		 * 1.5			70
		 * 2			75
		 * 3			80
		 * 4			85
		 * */
		if(videoMemCapacity.equals("128MB"))
			return 40;
		else if(videoMemCapacity.equals("256MB"))
			return 45;
		else if(videoMemCapacity.equals("512MB"))
			return 50;
		else if(videoMemCapacity.equals("768MB"))
			return 55;
		else if(videoMemCapacity.equals("1GB"))
			return 60;
		else if(videoMemCapacity.equals("1.25GB"))
			return 65;
		else if(videoMemCapacity.equals("1.5GB"))
			return 70;
		else if(videoMemCapacity.equals("2GB"))
			return 75;
		else if(videoMemCapacity.equals("3GB"))
			return 80;
		else if(videoMemCapacity.equals("4GB"))
			return 85;
		else return 90;
		
	}

}
